package com.yan.test.fastjson;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.json.JsonMapper;

import java.io.*;
import java.util.List;

/**
 * @author taoge
 * @Date 2024/8/13 18:55
 * @Description
 */
public class Jakson {
    public static void main(String[] args) throws IOException {
        JsonMapper mapper = new JsonMapper();
        //BufferedReader br = new BufferedReader(new FileReader("day18_code/src/com/yan/test/fastjson/books.json"));
        JsonNode jsonNode = mapper.readTree(new File("day18_code/src/com/yan/test/fastjson/books.json"));
        List<Book> list = mapper.readValue(new File("day18_code/src/com/yan/test/fastjson/books.json"), new TypeReference<List<Book>>() {});
        for (Book book : list) {
            System.out.println(book);
        }
    }
}
